package downpacket

import "gitee.com/yanwc/ebike-xiaoan-device/internal/field"

type BackWheelLockState int

const (
	BackWheelUnlock BackWheelLockState = 0
	BackWheelLock   BackWheelLockState = 1
)

type BackWheelLockReq struct {
	SW        BackWheelLockState `json:"sw"`
	PlayVoice *PlayVoiceReq
}

func NewBackWheelLockReq(sn field.SerialNumber, req BackWheelLockReq) *Req[BackWheelLockReq] {
	if req.PlayVoice != nil {
		if req.PlayVoice.Idx == 0 || req.PlayVoice.Url == "" || req.PlayVoice.CRC == 0 {
			req.PlayVoice = nil
		}
	}
	return &Req[BackWheelLockReq]{
		CmdWord: BackWheelLockCommandWord,
		MsgNo:   sn,
		Param:   req,
	}
}
